<template>
  <tr>
    <td><input type="checkbox" v-model="obj.checked" /></td>
    <td>{{ obj.name }}</td>
    <td>{{ obj.price }}</td>
    <td>
      <button @click="add">+</button>{{ obj.num
      }}<button @click="reduce">-</button>
    </td>
    <td>{{ sum }}</td>
    <td><button @click="del">删除</button></td>
  </tr>
</template>

<script>
export default {
  //!!!!!props加s
  props: ["obj", "sum", "index"],
  methods: {
    add() {
      return (this.obj.num += 1);
    },
    reduce() {
      return (this.obj.num = this.obj.num ? this.obj.num - 1 : this.obj.num);
    },
    del() {
      this.$emit("subObj", this.index);
      //console.log(this.index);
    },
  },
};
</script>

<style></style>
